/*
 * @Author: xiaorao 2930367909@qq.com
 * @Date: 2025-02-21 10:57:02
 * @LastEditors: xiaorao 2930367909@qq.com
 * @LastEditTime: 2025-02-21 10:57:15
 * @FilePath: \common\CommonVue\src\utils\storage.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const storage = {
  setLocal: function (key: any, value: any) {
    window.localStorage.setItem(key, JSON.stringify(value));
  },
  getLocal: function (key: any) {
    let value = String(window.localStorage.getItem(key));
    return JSON.parse(value);
  },
  setSession: function (key: any, value: any) {
    window.sessionStorage.setItem(key, JSON.stringify(value));
  },
  getSession: function (key: any) {
    let value = String(window.sessionStorage.getItem(key));
    return JSON.parse(value);
  },
  clearOneLocal: function (key: any) {
    window.localStorage.removeItem(key);
  },
  clearOneSession: function (key: any) {
    window.sessionStorage.removeItem(key);
  },
  clearAllLocal: function () {
    window.localStorage.clear();
  },
  clearAllSession: function () {
    window.sessionStorage.clear();
  },
};
export default storage;
